import React from 'react';
import { useNavigate } from 'react-router-dom';

import Contacts from '../MessageModule/Contacts';

// Contacts页面的包装组件，用于提供用户信息
export const ContactsWrapper: React.FC = () => {
  const savedUser = localStorage.getItem('currentUser');
  if (!savedUser) {
    // 如果没有用户信息，重定向到登录页面
    window.location.href = '/login';
    return null;
  }

  // 构造用户信息对象
  const userData = {
    username: loginUsername,
    image:
      localStorage.getItem('login_avatar') ||
      'https://img1.baidu.com/it/u=3217838212,795208401&fm=253&fmt=auto&app=138&f=JPEG?w=514&h=500',
    isLoggedIn: true,
  };

  return <Contacts currentUser={userData} />;
};
